<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>倒计时</title>
</head>
<body>
<script>
    var duration=60

    // 计时器句柄=setInterval(回调函数,每隔多长时间执行回调函数)
    //清除计时器:clearInterval(计时器句柄)
    intervalId =setInterval(function () {
        console.log(duration + "秒");
        if(duration===0){
            //清除定时器
            clearInterval(intervalId)
        }
        duration = duration-1
    },1000)

</script>
</body>
</html>